﻿@model EditRoleViewModel

@{
    ViewBag.Title = "编辑角色";
}

    <h1>编辑角色</h1>

<form asp-action="EditRole" method="post">
    <div class="form-group row">
        <label asp-for="Id" class="col-sm-2 col-form-label"></label>
        <div class="col-sm-10">
            <input asp-for="Id" class="form-control" disabled />
        </div>
    </div>

    <div class="form-group row">
        <label asp-for="RoleName" class="col-sm-2 col-form-label"></label>
        <div class="col-sm-10">
            <input asp-for="RoleName" class="form-control" placeholder="请输入角色名称" />
            <span asp-validation-for="RoleName" class="text-danger"></span>
        </div>
    </div>

    <div asp-validation-summary="All" class="text-danger"></div>
        
    <div class="form-group row">
        <div class="col-sm-10">
            <button type="submit" class="btn btn-primary">更新</button>
            <a class="btn btn-primary" asp-action="ListRoles">取消</a>
        </div>
    </div>
    
    <div class="card">
        <div class="card-header">
            <h3>该角色中的用户</h3>
        </div>
        <div class="card-body">
            @if (Model.Users.Any())
            {
                foreach (var item in Model.Users)
                {
                    <h5 class="card-title">@item</h5>
                }
            }
            else
            {
                <h5 class="card-title">目前没有信息</h5>
            }
        </div>
        
        <div class="card-footer">
            <a asp-controller="Admin" asp-action="EditUsersInRole" asp-route-roleId="@Model.Id" class="btn btn-outline-primary" style="width: auto">从角色中添加或删除用户</a>
        </div>
    </div>

</form>